﻿using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Gamey.Genesis
{
    class BinHeaderReader : RomReader
    {
        class NameFieldReader : CapitalizedFieldReader
        {
            static readonly Regex SpacesMatcher = new Regex(@"\s+", RegexOptions.Compiled);

            public NameFieldReader() : base(0x150, 32)
            { }

            protected override string Transform(string value)
            {
                // For some reason the name may have lots of spaces in it; let's normalize things by
                // consolidating multiple spaces into single spaces.
                return SpacesMatcher.Replace(base.Transform(value), " ");
            }
        }

        static readonly IDictionary<string, FieldReader> FieldReaders = new Dictionary<string, FieldReader>
        {
            { "Name", new NameFieldReader() }
        };

        protected override string RomFileExtension
        {
            get { return ".bin"; }
        }

        protected override IDictionary<string, FieldReader> GetFieldReaders()
        {
            return FieldReaders;
        }
    }
}
